package com.solvePlat.service.Impl;

import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import com.solvePlat.dao.TopicClassificationMapper;
import com.solvePlat.entity.TopicClassification;
import com.solvePlat.entity.TopicClassificationExample;
import com.solvePlat.entity.WorkInfo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.util.StringUtils;

import javax.annotation.Resource;
import java.util.List;

@Service
public class TopicClassificationServiceImpl {
    @Resource
    private TopicClassificationMapper topicClassificationMapper;

    public PageInfo selectTopicClassification(TopicClassification topicClassification){
        PageHelper.startPage(1,100);
        List<TopicClassification> topicClassificationList = topicClassificationMapper.selectTopicClassificatioNotParent("0");
        PageInfo<TopicClassification> pageInfo = new PageInfo<TopicClassification>(topicClassificationList);
        return pageInfo;
    }

    public List<TopicClassification> selectTopicClassificationListByTree(TopicClassification topicClassification){
        topicClassification.setUuid("0");
        //查询到顶级节点
        List<TopicClassification> topicClassificationList = topicClassificationMapper.selectTopicClassificationByParent(topicClassification.getUuid());
        for(TopicClassification top: topicClassificationList){
            List<TopicClassification> childrens = topicClassificationMapper.selectTopicClassificationByParent(top.getUuid());
            top.setTopicClassificationList(childrens);
        }
        return topicClassificationList;
    }

}
